package org.shoukaiseki.supersaiyan.db.inittable.system;

import org.shoukaiseki.inittable.domain.TableColumnInfo;
import org.shoukaiseki.inittable.domain.TableConstraintInfo;
import org.shoukaiseki.inittable.domain.TableIndexInfo;
import org.shoukaiseki.inittable.service.ITableBuildInfoService;
import org.shoukaiseki.kakaroto.annotation.TableBuild;

import java.util.List;

import static org.shoukaiseki.inittable.utils.SksColumnCamelCaseCommon.relationshipId;
import static org.shoukaiseki.inittable.utils.SksColumnCamelCaseCommon.uniqueId;
import static org.shoukaiseki.inittable.utils.TableColumnInfoBuilder.column;
import static org.shoukaiseki.inittable.utils.TableConstraintForeignKeyInfoBuilder.constraintName;
import static org.shoukaiseki.inittable.utils.TableIndexInfoBuilder.uniqueIndex;
import static org.shoukaiseki.inittable.utils.TableInfoUtils.*;


/**
 * OK
 * org.shoukaiseki.supersaiyan.db.inittable.system.SysRoleMenuInitTable
 * <br>
 *
 * @author shoukaiseki blog http://www.shoukaiseki.top/<br> E-mail jiang28555@Gmail.com<br>
 * @date 2022-10-15 13:45:21<br>
 */
@TableBuild(name = SysRoleMenuInitTable.TABLE_NAME, comment = "角色和菜单关联表",version = 1,primaryKey = "primary key (role_id, menu_id)")
public class SysRoleMenuInitTable implements ITableBuildInfoService {

    public static final String TABLE_NAME="sys_role_menu";

    @Override
    public List<TableColumnInfo> tableColumnInfoList(){
        List<TableColumnInfo> table = tableColumns(

                relationshipId("role_id","角色ID",null,true),
                relationshipId("menu_id","菜单ID",null,true),
                null
        );

        return table;
    }

    @Override
    public List<TableConstraintInfo> tableConstraintInfoList() {
        return TableConstraints(
                constraintName("fk_menu_id").relationTableName(SysMenuInitTable.TABLE_NAME).relationColumnName(SysMenuInitTable.COLUMN_MENU_ID),
                null
        );
    }
}
